from django.urls import path, include
from rest_framework.routers import DefaultRouter
from .views import (
    DepartmentListCreateView,
    DoctorListCreateView,
    ScheduleListView,
    DoctorScheduleView,
    TimeSlotListView,
    MedicalArticleViewSet,
    ArticleRecommendationView,
    ArticleDetailView,
    ArticleRecommendationAPIView,
)
from .es_utils.api import (
    import_articles_to_es,
    search_articles,
    sync_control,
)

router = DefaultRouter()
router.register(r'articles', MedicalArticleViewSet)

urlpatterns = [
    # 科室接口
    path('departments/', DepartmentListCreateView.as_view(), name='department-list'),

    # 医生接口
    path('doctors/', DoctorListCreateView.as_view(), name='doctor-list'),

    # 科室树接口

    # 排班相关
    path('schedules/', ScheduleListView.as_view(), name='schedule-list'),
    path('doctor-schedules/', DoctorScheduleView.as_view(), name='doctor-schedule-list'),
    path('time-slots/', TimeSlotListView.as_view(), name='time-slot-list'),
    
    # 预约表接口
    path('', include(router.urls)),
    
    # 文章推荐系统接口
    path('article-recommendation/', ArticleRecommendationView.as_view(), name='article-recommendation'),
    path('articles/recommendations/', ArticleRecommendationAPIView.as_view(), name='article-recommendations'),
    
    # Elasticsearch相关接口
    path('es/import-articles/', import_articles_to_es, name='import-articles-to-es'),
    path('es/search/', search_articles, name='search-articles'),
    path('es/sync/', sync_control, name='sync-control'),
    #详情
    path('articles/<int:article_id>/detail/', ArticleDetailView.as_view(), name='article-detail'),
]